package cn.icanci.ladybird.controller;

import cn.icanci.ladybird.common.result.JsonData;
import cn.icanci.ladybird.service.util.SendCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.mail.MessagingException;

/**
 * @author: icanci
 * @date: Created in 2020/10/14 14:54
 * @classAction: 发送验证码的控制层
 */
@Slf4j
@Controller
@RequestMapping("/api/v1/pub/common")
public class SendCodeController {
    @Autowired
    private SendCodeService sendCodeService;

    @ResponseBody
    @RequestMapping("/code")
    public JsonData getCode(String account, String isRegister) throws MessagingException {
        log.info("SendCodeController.getCode - " + account + " - " + isRegister);
        return sendCodeService.getCode(account, isRegister);
    }
}
